﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;
using VIW = CPPEI.ETL.Domain.Views;

namespace CPPEI.ETL.WebApi
{
    [CPPEI.WebApi.AuthGetAction("ETL", "GetCodeDataType", "1.0")]
    public class GetCodeDataTypeAction : BaseAction<GetCodeDataTypeParams, GetCodeDataTypeResult>
    {
        protected override ActionResult<GetCodeDataTypeResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            GetCodeDataTypeParams opParams)
        {
            Type[] types = new Type[]{
                typeof(string),
                typeof(int),
                typeof(double),
                typeof(float),
                typeof(long),
                typeof(DateTime),
                typeof(Guid),
                typeof(FileInfo)
            };

            GetCodeDataTypeResult result = new GetCodeDataTypeResult();
            foreach (var type in types)
            {
                GetCodeDataTypeResult.Item item = new GetCodeDataTypeResult.Item();
                item.Name = type.FullName;
                result.Items.Add(item);
            }
            return new ActionResult<GetCodeDataTypeResult>(result);
        }
    }

    public class GetCodeDataTypeParams
    {
    }

    public class GetCodeDataTypeResult
    {
        public List<Item> Items = new List<Item>();

        public class Item
        {
            public string Name { get; set; }
        }
    }
}
